﻿@model DatabaseEntities
@{
    ViewBag.Title = "DTweet Users List";

    var publicUsers = Model.Accounts;
    var currentUser = Static.CurrentUser;
}

@section H1
{
    <h1>
        DTweet Users List</h1>
}

@section UserName
{    
    @if(currentUser != null)
    {
        <div id="you" accesskey="@currentUser.UniqueToken">@currentUser.FullName.Truncate(20)</div>
    }    
}

@section Meta
{
    <link href="@Url.Content("~/Content/Styles/dashingquill.userslist.css")" rel="stylesheet" type="text/css" />
}

<div class="list-container">
    <table>
        <thead>
            <th>
                Name
            </th>
            <th>
                Tweets
            </th>
            <th>
                Following
            </th>
            <th>
                Followers
            </th>
            <th>
                Joined-At
            </th>
        </thead>
        @foreach (var user in publicUsers)
        {
            var tweetsCount = Model.Tweets.Where(t => t.UserToken == user.UniqueToken).Count();
            var following = Model.GetUsersFromHisCircles(user.UniqueToken);
            var followers = Model.GetOtherUsersWhoCircledHim(user.UniqueToken);
            
            <tr id="@user.UniqueToken">
                <td>
                    <a href="@Url.Content("~/" + user.UniqueToken)">@user.FullName</a>
                </td>
                <td class="tweet-count">@tweetsCount
                </td>
                <td>
                    <div class="following" accesskey="following">
                        @following.Count - <span style="color: Gray">@following.Members</span>                        
                    </div>
                    <div class="users-list"></div>
                </td>
                <td>
                    <div class="followers" accesskey="followers">
                        @followers.Count - <span style="color: Gray">@followers.Members</span>                        
                    </div>
                    <div class="users-list"></div>
                </td>
                <td>
                    @user.CreationDate.ToShortDateString()
                </td>
            </tr>
        }
    </table>
</div>
@section JavaScript
{
    <script src="@Url.Content("~/Content/JavaScript/dashingquill.userslist.js")" type="text/javascript"></script>
    <script>
        userslist.processAll();
    </script>
}

@if (publicUsers.Count() <= 0)
{
    <div style="padding: 20px; border: 1px solid red; font-size: 20px; color: red;">
        There is no user yet! <br /> <br />
        <a href="@Url.Content("~/Login")" style="color:blue;">Create New Account</a> (It is free and easy!!)
    </div>
}